package com.rocket.consumer;

import com.rocket.param.TeduClass;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.Message;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Component;

@Component
@RocketMQMessageListener(
        topic = "topicA",
        consumerGroup = "topicA-group",
        selectorExpression = "*"
)
public class TalkConsumerA implements RocketMQListener<String> {
    @Autowired
    private RocketMQTemplate rocketMQTemplate;

    @Override
    public void onMessage(String hello) {
        System.out.println("talkA接收到问候:" + hello);
        String txt = "你也好啊!";
        Message<String> message = MessageBuilder.withPayload(txt).build();
        rocketMQTemplate.syncSend("topicB",message);
    }


}
